package com.wealth.scsj.b_app.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.wealth.scsj.b_app.R;
import com.wealth.scsj.b_app.bean.DistributionInformationBean;

import java.util.List;

/**
 * 配送信息列表
 */
public class InformationShopAdapter extends RecyclerView.Adapter<InformationShopAdapter.MyViewHolder> {

    private Context mContext;
    private List<DistributionInformationBean.InformationBean> mList;
    private LayoutInflater mInflater;

    public InformationShopAdapter(Context context, List<DistributionInformationBean.InformationBean> data) {
        this.mContext = context;
        this.mList = data;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.item_information, parent, false);
        MyViewHolder viewHolder = new MyViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, final int position) {
        holder.mInformationKeyTv.setText(mList.get(position).getInformation_name());
        holder.mInformationValueTv.setText(mList.get(position).getInformation_value());
    }

    @Override
    public int getItemCount() {
        return mList.size();
    }

    public class MyViewHolder extends RecyclerView.ViewHolder {

        public TextView mInformationKeyTv;
        public TextView mInformationValueTv;

        public MyViewHolder(View itemView) {
            super(itemView);
            mInformationKeyTv =  itemView.findViewById(R.id.information_key_tv);
            mInformationValueTv =  itemView.findViewById(R.id.information_value_tv);
        }
    }

}
